#include <head.h>


void * Func_pthread(void * arg)
{
    printf("hello\n");
#if 0 
    // 栈空间 函数结束自动释放
    int val = 10;
    void * exit_val = &val;
#endif

#if 0
    static int val = 10;
    void * exit_val = &val;
#endif

#if 1
    int * val = malloc(4);
    *val = 10;
    void * exit_val = val;
#endif

    pthread_exit(exit_val);
}

int main(int argc, char const *argv[])
{
    // 线程的创建
    pthread_t tid;

    pthread_create(&tid , NULL , Func_pthread , NULL);
    
    // 线程的回收
    int val = 10;
    void * exit_val;
    pthread_join(tid , &exit_val);

    val = *((int *)exit_val);
    printf("val = %d\n" , val);
    return 0;
}